package leetcode_2501_2600;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LeeCode_2515 {
    public static void main(String[] args) {

    }

    private static int closetTarget(String[] words, String target, int startIndex) {
        int n = words.length;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (words[i].equals(target))
                list.add(i);
        }
        int ans = Integer.MAX_VALUE;
        for (Integer next : list) {
            ans = Math.min(ans, Math.abs(startIndex - next));
            ans = Math.min(ans, startIndex + n - next);
            ans = Math.min(ans, n - startIndex + next);
        }
        return ans == Integer.MAX_VALUE ? -1 : ans;
    }
}
